<?xml version="1.0" encoding="ascii"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
          "DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>bkn.bibtex.string_tools</title>
  <link rel="stylesheet" href="epydoc.css" type="text/css" />
  <script type="text/javascript" src="epydoc.js"></script>
</head>

<body bgcolor="white" text="black" link="blue" vlink="#204080"
      alink="#204080">
<!-- ==================== NAVIGATION BAR ==================== -->
<table class="navbar" border="0" width="100%" cellpadding="0"
       bgcolor="#a0c0ff" cellspacing="0">
  <tr valign="middle">
  <!-- Home link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="bkn.bibtex-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Tree link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Index link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Help link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Project homepage -->
      <th class="navbar" align="right" width="100%">
        <table border="0" cellpadding="0" cellspacing="0">
          <tr><th class="navbar" align="center"
            ><a class="navbar" target="_top" href="http://code.google.com/p/bibkn/">bkn.bibtex</a></th>
          </tr></table></th>
  </tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0">
  <tr valign="top">
    <td width="100%">
      <span class="breadcrumbs">
        Package&nbsp;bkn ::
        <a href="bkn.bibtex-module.html">Package&nbsp;bibtex</a> ::
        Module&nbsp;string_tools
      </span>
    </td>
    <td>
      <table cellpadding="0" cellspacing="0">
        <!-- hide/show private -->
        <tr><td align="right"><span class="options">[<a href="javascript:void(0);" class="privatelink"
    onclick="toggle_private();">hide&nbsp;private</a>]</span></td></tr>
        <tr><td align="right"><span class="options"
            >[<a href="frames.html" target="_top">frames</a
            >]&nbsp;|&nbsp;<a href="bkn.bibtex.string_tools-pysrc.html"
            target="_top">no&nbsp;frames</a>]</span></td></tr>
      </table>
    </td>
  </tr>
</table>
<h1 class="epydoc">Source Code for <a href="bkn.bibtex.string_tools-module.html">Module bkn.bibtex.string_tools</a></h1>
<pre class="py-src">
<a name="L1"></a><tt class="py-lineno">  1</tt>  <tt class="py-line"><tt class="py-docstring">'''Miscellaneous tools for working with BibTeX strings, mostly for</tt> </tt>
<a name="L2"></a><tt class="py-lineno">  2</tt>  <tt class="py-line"><tt class="py-docstring">converting between latex and other formats.</tt> </tt>
<a name="L3"></a><tt class="py-lineno">  3</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<a name="L4"></a><tt class="py-lineno">  4</tt>  <tt class="py-line"><tt class="py-docstring">@todo: add module level documentation.</tt> </tt>
<a name="L5"></a><tt class="py-lineno">  5</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<a name="L6"></a><tt class="py-lineno">  6</tt>  <tt class="py-line"><tt class="py-docstring">@copyright: (c) 2004-2009, Jim Pitman, Dept. Statistics, U.C. Berkeley</tt> </tt>
<a name="L7"></a><tt class="py-lineno">  7</tt>  <tt class="py-line"><tt class="py-docstring">    &lt;http://www.stat.berkeley.edu/users/pitman&gt;</tt> </tt>
<a name="L8"></a><tt class="py-lineno">  8</tt>  <tt class="py-line"><tt class="py-docstring">@copyright: (c) 2009-2010, Benjamin Kalish</tt> </tt>
<a name="L9"></a><tt class="py-lineno">  9</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<a name="L10"></a><tt class="py-lineno"> 10</tt>  <tt class="py-line"><tt class="py-docstring">@license:</tt> </tt>
<a name="L11"></a><tt class="py-lineno"> 11</tt>  <tt class="py-line"><tt class="py-docstring">    This program is free software; you can redistribute it and/or modify</tt> </tt>
<a name="L12"></a><tt class="py-lineno"> 12</tt>  <tt class="py-line"><tt class="py-docstring">    it under the terms of the GNU General Public License as published by</tt> </tt>
<a name="L13"></a><tt class="py-lineno"> 13</tt>  <tt class="py-line"><tt class="py-docstring">    the Free Software Foundation; either version 2 of the License, or</tt> </tt>
<a name="L14"></a><tt class="py-lineno"> 14</tt>  <tt class="py-line"><tt class="py-docstring">    (at your option) any later version.</tt> </tt>
<a name="L15"></a><tt class="py-lineno"> 15</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<a name="L16"></a><tt class="py-lineno"> 16</tt>  <tt class="py-line"><tt class="py-docstring">    This program is distributed in the hope that it will be useful, but</tt> </tt>
<a name="L17"></a><tt class="py-lineno"> 17</tt>  <tt class="py-line"><tt class="py-docstring">    WITHOUT ANY WARRANTY; without even the implied warranty of</tt> </tt>
<a name="L18"></a><tt class="py-lineno"> 18</tt>  <tt class="py-line"><tt class="py-docstring">    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU</tt> </tt>
<a name="L19"></a><tt class="py-lineno"> 19</tt>  <tt class="py-line"><tt class="py-docstring">    General Public License for more details.</tt> </tt>
<a name="L20"></a><tt class="py-lineno"> 20</tt>  <tt class="py-line"><tt class="py-docstring">'''</tt> </tt>
<a name="L21"></a><tt class="py-lineno"> 21</tt>  <tt class="py-line"> </tt>
<a name="L22"></a><tt class="py-lineno"> 22</tt>  <tt class="py-line"><tt class="py-keyword">import</tt> <tt class="py-name">re</tt> </tt>
<a name="L23"></a><tt class="py-lineno"> 23</tt>  <tt class="py-line"><tt class="py-keyword">import</tt> <tt class="py-name">string</tt> </tt>
<a name="L24"></a><tt class="py-lineno"> 24</tt>  <tt class="py-line"> </tt>
<a name="L25"></a><tt class="py-lineno"> 25</tt>  <tt class="py-line"><tt class="py-keyword">from</tt> <tt class="py-name">bkn</tt><tt class="py-op">.</tt><tt id="link-0" class="py-name" targets="Package bkn.bibtex=bkn.bibtex-module.html,Module bkn.bibtex.bibtex=bkn.bibtex.bibtex-module.html"><a title="bkn.bibtex
bkn.bibtex.bibtex" class="py-name" href="#" onclick="return doclink('link-0', 'bibtex', 'link-0');">bibtex</a></tt><tt class="py-op">.</tt><tt id="link-1" class="py-name" targets="Package bkn.bibtex.latex_converter=bkn.bibtex.latex_converter-module.html,Module bkn.bibtex.latex_converter.latex_converter=bkn.bibtex.latex_converter.latex_converter-module.html"><a title="bkn.bibtex.latex_converter
bkn.bibtex.latex_converter.latex_converter" class="py-name" href="#" onclick="return doclink('link-1', 'latex_converter', 'link-1');">latex_converter</a></tt><tt class="py-op">.</tt><tt id="link-2" class="py-name" targets="Module bkn.bibtex.latex_converter.latex2ascii_converter=bkn.bibtex.latex_converter.latex2ascii_converter-module.html"><a title="bkn.bibtex.latex_converter.latex2ascii_converter" class="py-name" href="#" onclick="return doclink('link-2', 'latex2ascii_converter', 'link-2');">latex2ascii_converter</a></tt> \ </tt>
<a name="L26"></a><tt class="py-lineno"> 26</tt>  <tt class="py-line">    <tt class="py-keyword">import</tt> <tt id="link-3" class="py-name" targets="Class bkn.bibtex.latex_converter.latex2ascii_converter.Latex2ASCIIConverter=bkn.bibtex.latex_converter.latex2ascii_converter.Latex2ASCIIConverter-class.html"><a title="bkn.bibtex.latex_converter.latex2ascii_converter.Latex2ASCIIConverter" class="py-name" href="#" onclick="return doclink('link-3', 'Latex2ASCIIConverter', 'link-3');">Latex2ASCIIConverter</a></tt> </tt>
<a name="L27"></a><tt class="py-lineno"> 27</tt>  <tt class="py-line"><tt class="py-keyword">from</tt> <tt class="py-name">bkn</tt><tt class="py-op">.</tt><tt id="link-4" class="py-name"><a title="bkn.bibtex
bkn.bibtex.bibtex" class="py-name" href="#" onclick="return doclink('link-4', 'bibtex', 'link-0');">bibtex</a></tt><tt class="py-op">.</tt><tt id="link-5" class="py-name"><a title="bkn.bibtex.latex_converter
bkn.bibtex.latex_converter.latex_converter" class="py-name" href="#" onclick="return doclink('link-5', 'latex_converter', 'link-1');">latex_converter</a></tt><tt class="py-op">.</tt><tt id="link-6" class="py-name" targets="Module bkn.bibtex.latex_converter.latex2html_converter=bkn.bibtex.latex_converter.latex2html_converter-module.html"><a title="bkn.bibtex.latex_converter.latex2html_converter" class="py-name" href="#" onclick="return doclink('link-6', 'latex2html_converter', 'link-6');">latex2html_converter</a></tt> \ </tt>
<a name="L28"></a><tt class="py-lineno"> 28</tt>  <tt class="py-line">    <tt class="py-keyword">import</tt> <tt id="link-7" class="py-name" targets="Class bkn.bibtex.latex_converter.latex2html_converter.Latex2HTMLConverter=bkn.bibtex.latex_converter.latex2html_converter.Latex2HTMLConverter-class.html"><a title="bkn.bibtex.latex_converter.latex2html_converter.Latex2HTMLConverter" class="py-name" href="#" onclick="return doclink('link-7', 'Latex2HTMLConverter', 'link-7');">Latex2HTMLConverter</a></tt> </tt>
<a name="L29"></a><tt class="py-lineno"> 29</tt>  <tt class="py-line"><tt class="py-keyword">from</tt> <tt class="py-name">bkn</tt><tt class="py-op">.</tt><tt id="link-8" class="py-name"><a title="bkn.bibtex
bkn.bibtex.bibtex" class="py-name" href="#" onclick="return doclink('link-8', 'bibtex', 'link-0');">bibtex</a></tt><tt class="py-op">.</tt><tt id="link-9" class="py-name"><a title="bkn.bibtex.latex_converter
bkn.bibtex.latex_converter.latex_converter" class="py-name" href="#" onclick="return doclink('link-9', 'latex_converter', 'link-1');">latex_converter</a></tt><tt class="py-op">.</tt><tt id="link-10" class="py-name" targets="Module bkn.bibtex.latex_converter.latex2unicode_converter=bkn.bibtex.latex_converter.latex2unicode_converter-module.html"><a title="bkn.bibtex.latex_converter.latex2unicode_converter" class="py-name" href="#" onclick="return doclink('link-10', 'latex2unicode_converter', 'link-10');">latex2unicode_converter</a></tt> \ </tt>
<a name="L30"></a><tt class="py-lineno"> 30</tt>  <tt class="py-line">    <tt class="py-keyword">import</tt> <tt id="link-11" class="py-name" targets="Class bkn.bibtex.latex_converter.latex2unicode_converter.Latex2UnicodeConverter=bkn.bibtex.latex_converter.latex2unicode_converter.Latex2UnicodeConverter-class.html"><a title="bkn.bibtex.latex_converter.latex2unicode_converter.Latex2UnicodeConverter" class="py-name" href="#" onclick="return doclink('link-11', 'Latex2UnicodeConverter', 'link-11');">Latex2UnicodeConverter</a></tt> </tt>
<a name="L31"></a><tt class="py-lineno"> 31</tt>  <tt class="py-line"> </tt>
<a name="L32"></a><tt class="py-lineno"> 32</tt>  <tt class="py-line"> </tt>
<a name="blank"></a><div id="blank-def"><a name="L33"></a><tt class="py-lineno"> 33</tt> <a class="py-toggle" href="#" id="blank-toggle" onclick="return toggle('blank');">-</a><tt class="py-line"><tt class="py-keyword">def</tt> <a class="py-def-name" href="bkn.bibtex.string_tools-module.html#blank">blank</a><tt class="py-op">(</tt><tt class="py-param">text</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="blank-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="blank-expanded"><a name="L34"></a><tt class="py-lineno"> 34</tt>  <tt class="py-line">    <tt class="py-docstring">'''Returns True if C{text} is C{None} or contains only whitespace.</tt> </tt>
<a name="L35"></a><tt class="py-lineno"> 35</tt>  <tt class="py-line"><tt class="py-docstring">    </tt> </tt>
<a name="L36"></a><tt class="py-lineno"> 36</tt>  <tt class="py-line"><tt class="py-docstring">    @param text: the string to test</tt> </tt>
<a name="L37"></a><tt class="py-lineno"> 37</tt>  <tt class="py-line"><tt class="py-docstring">    @type text: C{str}</tt> </tt>
<a name="L38"></a><tt class="py-lineno"> 38</tt>  <tt class="py-line"><tt class="py-docstring">    @rtype: C{bool}</tt> </tt>
<a name="L39"></a><tt class="py-lineno"> 39</tt>  <tt class="py-line"><tt class="py-docstring">    @returns:</tt> </tt>
<a name="L40"></a><tt class="py-lineno"> 40</tt>  <tt class="py-line"><tt class="py-docstring">        C{True} if C{text} is C{None} or contains only whitespace,</tt> </tt>
<a name="L41"></a><tt class="py-lineno"> 41</tt>  <tt class="py-line"><tt class="py-docstring">        C{False} otherwise.</tt> </tt>
<a name="L42"></a><tt class="py-lineno"> 42</tt>  <tt class="py-line"><tt class="py-docstring">    @raise AttributeError:</tt> </tt>
<a name="L43"></a><tt class="py-lineno"> 43</tt>  <tt class="py-line"><tt class="py-docstring">        blank() will raise an error if its input doesn't act like a</tt> </tt>
<a name="L44"></a><tt class="py-lineno"> 44</tt>  <tt class="py-line"><tt class="py-docstring">        string. (In particular, it must respond to the strip() method.</tt> </tt>
<a name="L45"></a><tt class="py-lineno"> 45</tt>  <tt class="py-line"><tt class="py-docstring">    '''</tt> </tt>
<a name="L46"></a><tt class="py-lineno"> 46</tt>  <tt class="py-line">     </tt>
<a name="L47"></a><tt class="py-lineno"> 47</tt>  <tt class="py-line">    <tt class="py-keyword">if</tt> <tt class="py-name">text</tt> <tt class="py-keyword">is</tt> <tt class="py-name">None</tt> <tt class="py-keyword">or</tt> <tt class="py-name">text</tt><tt class="py-op">.</tt><tt class="py-name">strip</tt><tt class="py-op">(</tt><tt class="py-op">)</tt> <tt class="py-op">==</tt> <tt class="py-string">''</tt><tt class="py-op">:</tt> <tt class="py-keyword">return</tt> <tt class="py-name">True</tt> </tt>
<a name="L48"></a><tt class="py-lineno"> 48</tt>  <tt class="py-line">    <tt class="py-keyword">return</tt> <tt class="py-name">False</tt> </tt>
</div><a name="L49"></a><tt class="py-lineno"> 49</tt>  <tt class="py-line"> </tt>
<a name="dehyphenate_words"></a><div id="dehyphenate_words-def"><a name="L50"></a><tt class="py-lineno"> 50</tt> <a class="py-toggle" href="#" id="dehyphenate_words-toggle" onclick="return toggle('dehyphenate_words');">-</a><tt class="py-line"><tt class="py-keyword">def</tt> <a class="py-def-name" href="bkn.bibtex.string_tools-module.html#dehyphenate_words">dehyphenate_words</a><tt class="py-op">(</tt><tt class="py-param">text</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="dehyphenate_words-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="dehyphenate_words-expanded"><a name="L51"></a><tt class="py-lineno"> 51</tt>  <tt class="py-line">    <tt class="py-docstring">'''Strips hyphens from hypenated words, ignoring, as much as</tt> </tt>
<a name="L52"></a><tt class="py-lineno"> 52</tt>  <tt class="py-line"><tt class="py-docstring">    possible, hyphens in other contexts.</tt> </tt>
<a name="L53"></a><tt class="py-lineno"> 53</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<a name="L54"></a><tt class="py-lineno"> 54</tt>  <tt class="py-line"><tt class="py-docstring">    This method removes only single hyphens between alphabetic</tt> </tt>
<a name="L55"></a><tt class="py-lineno"> 55</tt>  <tt class="py-line"><tt class="py-docstring">    characters. Removed hyphens are replaced with a space.</tt> </tt>
<a name="L56"></a><tt class="py-lineno"> 56</tt>  <tt class="py-line"><tt class="py-docstring">    '''</tt> </tt>
<a name="L57"></a><tt class="py-lineno"> 57</tt>  <tt class="py-line">    <tt class="py-comment"># This regular expression affects only single hyphens; multiple</tt> </tt>
<a name="L58"></a><tt class="py-lineno"> 58</tt>  <tt class="py-line">    <tt class="py-comment"># consecutive hyphens, which indicate dashes in LaTeX, will be</tt> </tt>
<a name="L59"></a><tt class="py-lineno"> 59</tt>  <tt class="py-line">    <tt class="py-comment"># ignored.</tt> </tt>
<a name="L60"></a><tt class="py-lineno"> 60</tt>  <tt class="py-line">    <tt class="py-keyword">return</tt> <tt class="py-name">re</tt><tt class="py-op">.</tt><tt class="py-name">sub</tt><tt class="py-op">(</tt><tt class="py-string">r'([a-zA-Z])-([a-zA-Z])'</tt><tt class="py-op">,</tt> <tt class="py-string">r'\1 \2'</tt><tt class="py-op">,</tt> <tt class="py-name">text</tt><tt class="py-op">)</tt> </tt>
</div><a name="L61"></a><tt class="py-lineno"> 61</tt>  <tt class="py-line"> </tt>
<a name="strip_punctuation"></a><div id="strip_punctuation-def"><a name="L62"></a><tt class="py-lineno"> 62</tt> <a class="py-toggle" href="#" id="strip_punctuation-toggle" onclick="return toggle('strip_punctuation');">-</a><tt class="py-line"><tt class="py-keyword">def</tt> <a class="py-def-name" href="bkn.bibtex.string_tools-module.html#strip_punctuation">strip_punctuation</a><tt class="py-op">(</tt><tt class="py-param">text</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="strip_punctuation-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="strip_punctuation-expanded"><a name="L63"></a><tt class="py-lineno"> 63</tt>  <tt class="py-line">    <tt class="py-docstring">'''Strips punctuation from the supplied string.'''</tt> </tt>
<a name="L64"></a><tt class="py-lineno"> 64</tt>  <tt class="py-line">    <tt class="py-name">chars</tt> <tt class="py-op">=</tt>  <tt class="py-op">[</tt><tt class="py-name">c</tt> <tt class="py-keyword">for</tt> <tt class="py-name">c</tt> <tt class="py-keyword">in</tt> <tt class="py-name">text</tt> <tt class="py-keyword">if</tt> <tt class="py-keyword">not</tt> <tt class="py-name">c</tt> <tt class="py-keyword">in</tt> <tt class="py-name">string</tt><tt class="py-op">.</tt><tt class="py-name">punctuation</tt><tt class="py-op">]</tt> </tt>
<a name="L65"></a><tt class="py-lineno"> 65</tt>  <tt class="py-line">    <tt class="py-keyword">return</tt> <tt class="py-string">''</tt><tt class="py-op">.</tt><tt class="py-name">join</tt><tt class="py-op">(</tt><tt class="py-name">chars</tt><tt class="py-op">)</tt> </tt>
</div><a name="L66"></a><tt class="py-lineno"> 66</tt>  <tt class="py-line"> </tt>
<a name="L67"></a><tt class="py-lineno"> 67</tt>  <tt class="py-line"><tt id="link-12" class="py-name" targets="Variable bkn.bibtex.string_tools.LATEX_2_ASCII_CONVERTER=bkn.bibtex.string_tools-module.html#LATEX_2_ASCII_CONVERTER"><a title="bkn.bibtex.string_tools.LATEX_2_ASCII_CONVERTER" class="py-name" href="#" onclick="return doclink('link-12', 'LATEX_2_ASCII_CONVERTER', 'link-12');">LATEX_2_ASCII_CONVERTER</a></tt> <tt class="py-op">=</tt> <tt id="link-13" class="py-name"><a title="bkn.bibtex.latex_converter.latex2ascii_converter.Latex2ASCIIConverter" class="py-name" href="#" onclick="return doclink('link-13', 'Latex2ASCIIConverter', 'link-3');">Latex2ASCIIConverter</a></tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
<a name="L68"></a><tt class="py-lineno"> 68</tt>  <tt class="py-line"><tt class="py-string">'''A L{Latex2ASCIIConverter} instance.</tt> </tt>
<a name="L69"></a><tt class="py-lineno"> 69</tt>  <tt class="py-line"><tt class="py-string">@type: L{Latex2ASCIIConverter}</tt> </tt>
<a name="L70"></a><tt class="py-lineno"> 70</tt>  <tt class="py-line"><tt class="py-string">'''</tt> </tt>
<a name="L71"></a><tt class="py-lineno"> 71</tt>  <tt class="py-line"> </tt>
<a name="tex2ascii"></a><div id="tex2ascii-def"><a name="L72"></a><tt class="py-lineno"> 72</tt> <a class="py-toggle" href="#" id="tex2ascii-toggle" onclick="return toggle('tex2ascii');">-</a><tt class="py-line"><tt class="py-keyword">def</tt> <a class="py-def-name" href="bkn.bibtex.string_tools-module.html#tex2ascii">tex2ascii</a><tt class="py-op">(</tt><tt class="py-param">tex</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="tex2ascii-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="tex2ascii-expanded"><a name="L73"></a><tt class="py-lineno"> 73</tt>  <tt class="py-line">    <tt class="py-docstring">'''Convert TeX accents, math expressions, etc. to ASCII.</tt> </tt>
<a name="L74"></a><tt class="py-lineno"> 74</tt>  <tt class="py-line"><tt class="py-docstring">    </tt> </tt>
<a name="L75"></a><tt class="py-lineno"> 75</tt>  <tt class="py-line"><tt class="py-docstring">    This function is simply a convenient wrapper for the methods provided</tt> </tt>
<a name="L76"></a><tt class="py-lineno"> 76</tt>  <tt class="py-line"><tt class="py-docstring">    in the bkn.bibtex.latex_converter package.</tt> </tt>
<a name="L77"></a><tt class="py-lineno"> 77</tt>  <tt class="py-line"><tt class="py-docstring">    </tt> </tt>
<a name="L78"></a><tt class="py-lineno"> 78</tt>  <tt class="py-line"><tt class="py-docstring">    @param tex: the TeX or LaTeX code to be converted.</tt> </tt>
<a name="L79"></a><tt class="py-lineno"> 79</tt>  <tt class="py-line"><tt class="py-docstring">    @type tex: C{str}</tt> </tt>
<a name="L80"></a><tt class="py-lineno"> 80</tt>  <tt class="py-line"><tt class="py-docstring">    @rtype: C{str}</tt> </tt>
<a name="L81"></a><tt class="py-lineno"> 81</tt>  <tt class="py-line"><tt class="py-docstring">    @return:</tt> </tt>
<a name="L82"></a><tt class="py-lineno"> 82</tt>  <tt class="py-line"><tt class="py-docstring">        a human readable representation of the string produced by using</tt> </tt>
<a name="L83"></a><tt class="py-lineno"> 83</tt>  <tt class="py-line"><tt class="py-docstring">        ASCII characters in place of LaTeX code where possible. Note that</tt> </tt>
<a name="L84"></a><tt class="py-lineno"> 84</tt>  <tt class="py-line"><tt class="py-docstring">        while this string consists only of ascii characters, it is still</tt> </tt>
<a name="L85"></a><tt class="py-lineno"> 85</tt>  <tt class="py-line"><tt class="py-docstring">        represented as Unicode internally!</tt> </tt>
<a name="L86"></a><tt class="py-lineno"> 86</tt>  <tt class="py-line"><tt class="py-docstring">    @warning: this is an inherently lossy conversion</tt> </tt>
<a name="L87"></a><tt class="py-lineno"> 87</tt>  <tt class="py-line"><tt class="py-docstring">    @todo: add real world examples to the documentation for this method</tt> </tt>
<a name="L88"></a><tt class="py-lineno"> 88</tt>  <tt class="py-line"><tt class="py-docstring">    '''</tt> </tt>
<a name="L89"></a><tt class="py-lineno"> 89</tt>  <tt class="py-line">    <tt class="py-comment"># the .encode('ascii') should not be neccesary, but it is best to be safe!</tt> </tt>
<a name="L90"></a><tt class="py-lineno"> 90</tt>  <tt class="py-line">    <tt class="py-keyword">return</tt> <tt id="link-14" class="py-name"><a title="bkn.bibtex.string_tools.LATEX_2_ASCII_CONVERTER" class="py-name" href="#" onclick="return doclink('link-14', 'LATEX_2_ASCII_CONVERTER', 'link-12');">LATEX_2_ASCII_CONVERTER</a></tt><tt class="py-op">.</tt><tt id="link-15" class="py-name" targets="Method bkn.bibtex.latex_converter.latex_converter.LatexConverter.convert()=bkn.bibtex.latex_converter.latex_converter.LatexConverter-class.html#convert"><a title="bkn.bibtex.latex_converter.latex_converter.LatexConverter.convert" class="py-name" href="#" onclick="return doclink('link-15', 'convert', 'link-15');">convert</a></tt><tt class="py-op">(</tt><tt class="py-name">tex</tt><tt class="py-op">)</tt> </tt>
</div><a name="L91"></a><tt class="py-lineno"> 91</tt>  <tt class="py-line"> </tt>
<a name="L92"></a><tt class="py-lineno"> 92</tt>  <tt class="py-line"><tt id="link-16" class="py-name" targets="Variable bkn.bibtex.string_tools.LATEX_2_HTML_CONVERTER=bkn.bibtex.string_tools-module.html#LATEX_2_HTML_CONVERTER"><a title="bkn.bibtex.string_tools.LATEX_2_HTML_CONVERTER" class="py-name" href="#" onclick="return doclink('link-16', 'LATEX_2_HTML_CONVERTER', 'link-16');">LATEX_2_HTML_CONVERTER</a></tt> <tt class="py-op">=</tt> <tt id="link-17" class="py-name"><a title="bkn.bibtex.latex_converter.latex2html_converter.Latex2HTMLConverter" class="py-name" href="#" onclick="return doclink('link-17', 'Latex2HTMLConverter', 'link-7');">Latex2HTMLConverter</a></tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
<a name="L93"></a><tt class="py-lineno"> 93</tt>  <tt class="py-line"><tt class="py-string">'''A L{Latex2HTMLConverter} instance.</tt> </tt>
<a name="L94"></a><tt class="py-lineno"> 94</tt>  <tt class="py-line"><tt class="py-string">@type: L{Latex2HTMLConverter}</tt> </tt>
<a name="L95"></a><tt class="py-lineno"> 95</tt>  <tt class="py-line"><tt class="py-string">'''</tt> </tt>
<a name="L96"></a><tt class="py-lineno"> 96</tt>  <tt class="py-line"> </tt>
<a name="tex2html"></a><div id="tex2html-def"><a name="L97"></a><tt class="py-lineno"> 97</tt> <a class="py-toggle" href="#" id="tex2html-toggle" onclick="return toggle('tex2html');">-</a><tt class="py-line"><tt class="py-keyword">def</tt> <a class="py-def-name" href="bkn.bibtex.string_tools-module.html#tex2html">tex2html</a><tt class="py-op">(</tt><tt class="py-param">tex</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="tex2html-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="tex2html-expanded"><a name="L98"></a><tt class="py-lineno"> 98</tt>  <tt class="py-line">    <tt class="py-docstring">'''Convert TeX accents, math expressions, etc. to HTML.</tt> </tt>
<a name="L99"></a><tt class="py-lineno"> 99</tt>  <tt class="py-line"><tt class="py-docstring">    </tt> </tt>
<a name="L100"></a><tt class="py-lineno">100</tt>  <tt class="py-line"><tt class="py-docstring">    @note:</tt> </tt>
<a name="L101"></a><tt class="py-lineno">101</tt>  <tt class="py-line"><tt class="py-docstring">        This function is simply a convenient wrapper for the methods</tt> </tt>
<a name="L102"></a><tt class="py-lineno">102</tt>  <tt class="py-line"><tt class="py-docstring">        provided in the bkn.bibtex.latex_converter package.</tt> </tt>
<a name="L103"></a><tt class="py-lineno">103</tt>  <tt class="py-line"><tt class="py-docstring">    @param tex: the TeX or LaTeX code to be converted.</tt> </tt>
<a name="L104"></a><tt class="py-lineno">104</tt>  <tt class="py-line"><tt class="py-docstring">    @type tex: C{str}</tt> </tt>
<a name="L105"></a><tt class="py-lineno">105</tt>  <tt class="py-line"><tt class="py-docstring">    @rtype: C{str}</tt> </tt>
<a name="L106"></a><tt class="py-lineno">106</tt>  <tt class="py-line"><tt class="py-docstring">    @return:</tt> </tt>
<a name="L107"></a><tt class="py-lineno">107</tt>  <tt class="py-line"><tt class="py-docstring">        a human readable representation of the string produced by using</tt> </tt>
<a name="L108"></a><tt class="py-lineno">108</tt>  <tt class="py-line"><tt class="py-docstring">        HTML code in place of LaTeX code where possible.</tt> </tt>
<a name="L109"></a><tt class="py-lineno">109</tt>  <tt class="py-line"><tt class="py-docstring">    @warning: this is an inherently lossy conversion</tt> </tt>
<a name="L110"></a><tt class="py-lineno">110</tt>  <tt class="py-line"><tt class="py-docstring">    @todo: add real world examples to the documentation for this method</tt> </tt>
<a name="L111"></a><tt class="py-lineno">111</tt>  <tt class="py-line"><tt class="py-docstring">    '''</tt> </tt>
<a name="L112"></a><tt class="py-lineno">112</tt>  <tt class="py-line">    <tt class="py-keyword">return</tt> <tt id="link-18" class="py-name"><a title="bkn.bibtex.string_tools.LATEX_2_HTML_CONVERTER" class="py-name" href="#" onclick="return doclink('link-18', 'LATEX_2_HTML_CONVERTER', 'link-16');">LATEX_2_HTML_CONVERTER</a></tt><tt class="py-op">.</tt><tt id="link-19" class="py-name"><a title="bkn.bibtex.latex_converter.latex_converter.LatexConverter.convert" class="py-name" href="#" onclick="return doclink('link-19', 'convert', 'link-15');">convert</a></tt><tt class="py-op">(</tt><tt class="py-name">tex</tt><tt class="py-op">)</tt> </tt>
</div><a name="L113"></a><tt class="py-lineno">113</tt>  <tt class="py-line"> </tt>
<a name="L114"></a><tt class="py-lineno">114</tt>  <tt class="py-line"><tt id="link-20" class="py-name" targets="Variable bkn.bibtex.string_tools.LATEX_2_UNICODE_CONVERTER=bkn.bibtex.string_tools-module.html#LATEX_2_UNICODE_CONVERTER"><a title="bkn.bibtex.string_tools.LATEX_2_UNICODE_CONVERTER" class="py-name" href="#" onclick="return doclink('link-20', 'LATEX_2_UNICODE_CONVERTER', 'link-20');">LATEX_2_UNICODE_CONVERTER</a></tt> <tt class="py-op">=</tt> <tt id="link-21" class="py-name"><a title="bkn.bibtex.latex_converter.latex2unicode_converter.Latex2UnicodeConverter" class="py-name" href="#" onclick="return doclink('link-21', 'Latex2UnicodeConverter', 'link-11');">Latex2UnicodeConverter</a></tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
<a name="L115"></a><tt class="py-lineno">115</tt>  <tt class="py-line"><tt class="py-string">'''A L{Latex2UnicodeConverter} instance.</tt> </tt>
<a name="L116"></a><tt class="py-lineno">116</tt>  <tt class="py-line"><tt class="py-string">@type: L{Latex2UnicodeConverter}</tt> </tt>
<a name="L117"></a><tt class="py-lineno">117</tt>  <tt class="py-line"><tt class="py-string">'''</tt> </tt>
<a name="L118"></a><tt class="py-lineno">118</tt>  <tt class="py-line"> </tt>
<a name="tex2unicode"></a><div id="tex2unicode-def"><a name="L119"></a><tt class="py-lineno">119</tt> <a class="py-toggle" href="#" id="tex2unicode-toggle" onclick="return toggle('tex2unicode');">-</a><tt class="py-line"><tt class="py-keyword">def</tt> <a class="py-def-name" href="bkn.bibtex.string_tools-module.html#tex2unicode">tex2unicode</a><tt class="py-op">(</tt><tt class="py-param">tex</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="tex2unicode-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="tex2unicode-expanded"><a name="L120"></a><tt class="py-lineno">120</tt>  <tt class="py-line">    <tt class="py-docstring">'''Convert TeX accents, math expressions, etc. to Unicode.</tt> </tt>
<a name="L121"></a><tt class="py-lineno">121</tt>  <tt class="py-line"><tt class="py-docstring">    </tt> </tt>
<a name="L122"></a><tt class="py-lineno">122</tt>  <tt class="py-line"><tt class="py-docstring">    This function is simply a convenient wrapper for the methods provided</tt> </tt>
<a name="L123"></a><tt class="py-lineno">123</tt>  <tt class="py-line"><tt class="py-docstring">    in the bkn.bibtex.latex_converter package.</tt> </tt>
<a name="L124"></a><tt class="py-lineno">124</tt>  <tt class="py-line"><tt class="py-docstring"> </tt> </tt>
<a name="L125"></a><tt class="py-lineno">125</tt>  <tt class="py-line"><tt class="py-docstring">    @param tex: the TeX or LaTeX code to be converted.</tt> </tt>
<a name="L126"></a><tt class="py-lineno">126</tt>  <tt class="py-line"><tt class="py-docstring">    @type tex: C{str}</tt> </tt>
<a name="L127"></a><tt class="py-lineno">127</tt>  <tt class="py-line"><tt class="py-docstring">    @rtype: C{str}</tt> </tt>
<a name="L128"></a><tt class="py-lineno">128</tt>  <tt class="py-line"><tt class="py-docstring">    @return:</tt> </tt>
<a name="L129"></a><tt class="py-lineno">129</tt>  <tt class="py-line"><tt class="py-docstring">        a human readable representation of the string produced by using</tt> </tt>
<a name="L130"></a><tt class="py-lineno">130</tt>  <tt class="py-line"><tt class="py-docstring">        Unicode characters in place of LaTeX code where possible.</tt> </tt>
<a name="L131"></a><tt class="py-lineno">131</tt>  <tt class="py-line"><tt class="py-docstring">    @warning: this is an inherently lossy conversion</tt> </tt>
<a name="L132"></a><tt class="py-lineno">132</tt>  <tt class="py-line"><tt class="py-docstring">    @todo: add real world examples to the documentation for this method</tt> </tt>
<a name="L133"></a><tt class="py-lineno">133</tt>  <tt class="py-line"><tt class="py-docstring">    '''</tt> </tt>
<a name="L134"></a><tt class="py-lineno">134</tt>  <tt class="py-line">    <tt class="py-keyword">return</tt> <tt id="link-22" class="py-name"><a title="bkn.bibtex.string_tools.LATEX_2_UNICODE_CONVERTER" class="py-name" href="#" onclick="return doclink('link-22', 'LATEX_2_UNICODE_CONVERTER', 'link-20');">LATEX_2_UNICODE_CONVERTER</a></tt><tt class="py-op">.</tt><tt id="link-23" class="py-name"><a title="bkn.bibtex.latex_converter.latex_converter.LatexConverter.convert" class="py-name" href="#" onclick="return doclink('link-23', 'convert', 'link-15');">convert</a></tt><tt class="py-op">(</tt><tt class="py-name">tex</tt><tt class="py-op">)</tt> </tt>
</div><a name="L135"></a><tt class="py-lineno">135</tt>  <tt class="py-line"> </tt><script type="text/javascript">
<!--
expandto(location.href);
// -->
</script>
</pre>
<br />
<!-- ==================== NAVIGATION BAR ==================== -->
<table class="navbar" border="0" width="100%" cellpadding="0"
       bgcolor="#a0c0ff" cellspacing="0">
  <tr valign="middle">
  <!-- Home link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="bkn.bibtex-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Tree link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Index link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Help link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Project homepage -->
      <th class="navbar" align="right" width="100%">
        <table border="0" cellpadding="0" cellspacing="0">
          <tr><th class="navbar" align="center"
            ><a class="navbar" target="_top" href="http://code.google.com/p/bibkn/">bkn.bibtex</a></th>
          </tr></table></th>
  </tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" width="100%%">
  <tr>
    <td align="left" class="footer">
    Generated by Epydoc 3.0.1 on Sun Jul  4 23:10:59 2010
    </td>
    <td align="right" class="footer">
      <a target="mainFrame" href="http://epydoc.sourceforge.net"
        >http://epydoc.sourceforge.net</a>
    </td>
  </tr>
</table>

<script type="text/javascript">
  <!--
  // Private objects are initially displayed (because if
  // javascript is turned off then we want them to be
  // visible); but by default, we want to hide them.  So hide
  // them unless we have a cookie that says to show them.
  checkCookie();
  // -->
</script>
</body>
</html>
